home *** CD-ROM | disk | FTP | other *** search
/ GRAVIS Top 100 #3 / GRAVIS CD No3_Fruhjahr_95.cdr / GRAVIS / PD u. Shareware / Bildschirmschoner / Basic Black 1.4.1 / Source / BBcdev.c < prev    next >
Text File  |  1994-08-09  |  18KB  |  593 lines

  1. /**********************************************************
  2.  *    Basic Black © 1993,1994 by Mason L. Bliss
  3.  *    All Rights Reserved
  4.  *    version 1.4.1
  5.  *
  6.  *    This cdev code uses the sample cdev class included with
  7.  *    the Think C 5.0.4 compiler. To build the project, you
  8.  *    will have to supply the Symantec code or an equivalent.
  9.  *
  10.  *    The important bits involve the use of the Gestalt manager
  11.  *    for cdev/INIT communication, to which the cdev mechanism
  12.  *    itself is irrelevant.
  13.  **********************************************************/
  14.  
  15. #include <cdev.h>
  16. #include <GestaltEqu.h>
  17. #include "BBcdev.h"
  18. #include "BB.h"
  19.  
  20.  
  21.  
  22. /**********************************************************
  23.  *    BBcdev::Init
  24.  *
  25.  *    This method initializes stuff.
  26.  **********************************************************/
  27. void BBcdev::Init(void)
  28. {
  29.     PrefStructureHandle    prefHandle;
  30.     ControlHandle        theControl;
  31.     short                controlValue;
  32.     long                theLong, width, height;
  33.     Rect                box;
  34.     Str255                theString;
  35.  
  36.     /* Initialize stuff */
  37.     inherited::Init();
  38.     
  39.     /* Get our preferences data */
  40.     prefHandle = (PrefStructureHandle) GetIndResource('PREF', 1);
  41.     if (ResError()) {
  42.         Error(cdevResErr);
  43.         return;
  44.     }
  45.     
  46.     /* Load & Lock Picture Resources */
  47.     pictHandles[0] = GetResource('PICT', topLeftPict);
  48.     pictHandles[1] = GetResource('PICT', topRightPict);
  49.     pictHandles[2] = GetResource('PICT', botRightPict);
  50.     pictHandles[3] = GetResource('PICT', botLeftPict);
  51.     pictHandles[4] = GetResource('PICT', noArrowPict);
  52.     pictHandles[5] = GetResource('PICT', upArrowPict);
  53.     pictHandles[6] = GetResource('PICT', dnArrowPict);
  54.     pictHandles[7] = GetResource('PICT', grArrowPict);
  55.     HLock(pictHandles[0]);
  56.     HLock(pictHandles[1]);
  57.     HLock(pictHandles[2]);
  58.     HLock(pictHandles[3]);
  59.     HLock(pictHandles[4]);
  60.     HLock(pictHandles[5]);
  61.     HLock(pictHandles[6]);
  62.     HLock(pictHandles[7]);
  63.  
  64.     /* get the sleep corner info */
  65.     sleepNowRect = (**prefHandle).sleepNowCorner;
  66.     GetDItem(dp, lastItem - initDev + sleepNow,
  67.                 &controlValue, &theControl, &box);
  68.     SetDItem(dp, lastItem - initDev + sleepNow,
  69.                 controlValue, pictHandles[sleepNowRect], &box);
  70.     InsetRect(&box, 3, 3);
  71.     EraseRect(&box);
  72.     InsetRect(&box, -3, -3);
  73.     DrawPicture(pictHandles[sleepNowRect], &box);
  74.     
  75.     width  = ((box.right - box.left) / 2);
  76.     height = ((box.bottom - box.top) / 2);
  77.     
  78.     /* Set up some small rects */
  79.     smallSNRect[0] = box;
  80.     smallSNRect[0].right -= width;
  81.     smallSNRect[0].bottom -= height;
  82.     smallSNRect[1] = box;
  83.     smallSNRect[1].left += width;
  84.     smallSNRect[1].bottom -= height;
  85.     smallSNRect[2] = box;
  86.     smallSNRect[2].left += width;
  87.     smallSNRect[2].top += height;
  88.     smallSNRect[3] = box;
  89.     smallSNRect[3].right -= width;
  90.     smallSNRect[3].top += height;
  91.     
  92.     /* get the wake corner info */
  93.     neverSleepRect = (**prefHandle).sleepNeverCorner;
  94.     GetDItem(dp, lastItem - initDev + neverSleep,
  95.                 &controlValue, &theControl, &box);
  96.     SetDItem(dp, lastItem - initDev + neverSleep,
  97.                 controlValue, pictHandles[neverSleepRect], &box);
  98.     InsetRect(&box, 3, 3);
  99.     EraseRect(&box);
  100.     InsetRect(&box, -3, -3);
  101.     DrawPicture(pictHandles[neverSleepRect], &box);
  102.  
  103.     width  = ((box.right - box.left) / 2);
  104.     height = ((box.bottom - box.top) / 2);
  105.  
  106.     /* Set up more small rects */
  107.     smallNSRect[0] = box;
  108.     smallNSRect[0].right -= width;
  109.     smallNSRect[0].bottom -= height;
  110.     smallNSRect[1] = box;
  111.     smallNSRect[1].left += width;
  112.     smallNSRect[1].bottom -= height;
  113.     smallNSRect[2] = box;
  114.     smallNSRect[2].left += width;
  115.     smallNSRect[2].top += height;
  116.     smallNSRect[3] = box;
  117.     smallNSRect[3].right -= width;
  118.     smallNSRect[3].top += height;
  119.             
  120.     /* get the clock checkbox */
  121.     GetDItem(dp, lastItem - initDev + clockOn, &controlValue, &theControl, &box);
  122.     if ((**prefHandle).bounceClock)
  123.         SetCtlValue(theControl, 1);
  124.     
  125.     /* get the "screen saver on" checkbox */
  126.     GetDItem(dp, lastItem - initDev + screenOn, &controlValue, &theControl, &box);
  127.     if ((**prefHandle).saverOn)
  128.         SetCtlValue(theControl, 1);
  129.     
  130.     /* get the "Show Startup Icon" checkbox */
  131.     GetDItem(dp, lastItem - initDev + startupIcon, &controlValue, &theControl, &box);
  132.     if ((**prefHandle).showIcon)
  133.         SetCtlValue(theControl, 1);
  134.     
  135.     /* get the "Fade To White" checkbox */
  136.     GetDItem(dp, lastItem - initDev + fadeWhite, &controlValue, &theControl, &box);
  137.     if ((**prefHandle).fadeToWhite)
  138.         SetCtlValue(theControl, 1);
  139.  
  140.     /* get the "Zero Menubar" checkbox */
  141.     GetDItem(dp, lastItem - initDev + zeroMenu, &controlValue, &theControl, &box);
  142.     if ((**prefHandle).zeroBar)
  143.         SetCtlValue(theControl, 1);
  144.  
  145.     /* get the "EraseRect" checkbox */
  146.     GetDItem(dp, lastItem - initDev + eraseRect, &controlValue, &theControl, &box);
  147.     if ((**prefHandle).eraseRectPatch)
  148.         SetCtlValue(theControl, 1);
  149.     
  150.     /* get the "EraseOval" checkbox */
  151.     GetDItem(dp, lastItem - initDev + eraseOval, &controlValue, &theControl, &box);
  152.     if ((**prefHandle).eraseOvalPatch)
  153.         SetCtlValue(theControl, 1);
  154.     
  155.     /* get the "EraseRgn" checkbox */
  156.     GetDItem(dp, lastItem - initDev + eraseRgn, &controlValue, &theControl, &box);
  157.     if ((**prefHandle).eraseRgnPatch)
  158.         SetCtlValue(theControl, 1);
  159.     
  160.     /* get the "DrawMenuBar" checkbox */
  161.     GetDItem(dp, lastItem - initDev + drawMenu, &controlValue, &theControl, &box);
  162.     if ((**prefHandle).drawMenuBarPatch)
  163.         SetCtlValue(theControl, 1);
  164.     
  165.     /* get the "InitCursor" checkbox */
  166.     GetDItem(dp, lastItem - initDev + initCurs, &controlValue, &theControl, &box);
  167.     if ((**prefHandle).initCursorPatch)
  168.         SetCtlValue(theControl, 1);
  169.     
  170.     /* get the idle time edit text item */
  171.     GetDItem(dp, lastItem - initDev + idleMins, &controlValue, &theControl, &box);
  172.     theLong = (long) (**prefHandle).idleTime;
  173.     NumToString(theLong, theString);
  174.     SetIText(theControl, theString);
  175.     SelIText(dp, lastItem - initDev + idleMins, 0, 32767);
  176.  
  177.     GetDItem(dp, lastItem - initDev + idleRect, &controlValue, &theControl, &box);
  178.     height = ((box.bottom - box.top) / 2);
  179.     smIdleRect = box;
  180.     smIdleRect.bottom -= height;
  181.     
  182.     /* get the refresh time edit text item */
  183.     GetDItem(dp, lastItem - initDev + refreshSecs, &controlValue, &theControl, &box);
  184.     theLong = (long) (**prefHandle).refreshSeconds;
  185.     NumToString(theLong, theString);
  186.     SetIText(theControl, theString);
  187.  
  188.     GetDItem(dp, lastItem - initDev + refrRect, &controlValue, &theControl, &box);
  189.     height = ((box.bottom - box.top) / 2);
  190.     smRefrRect = box;
  191.     smRefrRect.bottom -= height;
  192.  
  193.     /* see if the idle time and refresh secs arrows need to be grey */
  194.     if (Gestalt('sysv', &theLong) != noErr || theLong < 0x700) {
  195.         GetDItem(dp, lastItem - initDev + idleRect,
  196.                         &controlValue, &theControl, &box);
  197.         SetDItem(dp, lastItem - initDev + idleRect,
  198.                 controlValue, pictHandles[grArrow], &box);
  199.         GetDItem(dp, lastItem - initDev + refrRect,
  200.                         &controlValue, &theControl, &box);
  201.         SetDItem(dp, lastItem - initDev + refrRect,
  202.                 controlValue, pictHandles[grArrow], &box);
  203.     }
  204.  
  205.     ReleaseResource(prefHandle);
  206. }
  207.  
  208.  
  209.  
  210. /**********************************************************
  211.  *    BBcdev::Idle
  212.  *
  213.  *    Fix the EditText items if needed.
  214.  **********************************************************/
  215. void BBcdev::Idle(void)
  216. {
  217.     ControlHandle    theControl;
  218.     short            controlValue;
  219.     long            theLong;
  220.     Rect            box;
  221.     Str255            theString;
  222.     
  223.     if (mustRemember) {
  224.         mustRemember = false;
  225.         /* fix the idle time information if needed */
  226.         GetDItem(dp, lastItem - initDev + idleMins, &controlValue, &theControl, &box);
  227.         GetIText(theControl, theString);
  228.         StringToNum(theString, &theLong);
  229.         if (theLong < 1) {
  230.             SetIText(theControl, "\p1");
  231.             SelIText(dp, lastItem - initDev + idleMins, 0, 32767);
  232.         } else if (theLong > 60) {
  233.             SetIText(theControl, "\p60");
  234.             SelIText(dp, lastItem - initDev + idleMins, 0, 32767);
  235.         }
  236.     
  237.         /* fix the refresh time information if needed */
  238.         GetDItem(dp, lastItem - initDev + refreshSecs, &controlValue, &theControl, &box);
  239.         GetIText(theControl, theString);
  240.         StringToNum(theString, &theLong);
  241.         if (theLong < 1) {
  242.             SetIText(theControl, "\p1");
  243.             SelIText(dp, lastItem - initDev + refreshSecs, 0, 32767);
  244.         } else if (theLong > 20) {
  245.             SetIText(theControl, "\p20");
  246.             SelIText(dp, lastItem - initDev + refreshSecs, 0, 32767);
  247.         }
  248.         RememberValues();
  249.     }
  250. }
  251.  
  252.  
  253.  
  254. /**********************************************************
  255.  *    BBcdev::Close
  256.  *
  257.  *    This method releases the 'PICT' resources.
  258.  **********************************************************/
  259. void BBcdev::Close(void)
  260. {
  261.     short    i;
  262.     
  263.     for (i = 0; i < 7; ++i) {
  264.         HUnlock(pictHandles[i]);
  265.         ReleaseResource(pictHandles[i]);
  266.     }
  267.     
  268.     inherited::Close();
  269. }
  270.  
  271.  
  272.  
  273. /**********************************************************
  274.  *    BBcdev::Key
  275.  *
  276.  *    This filters out invalid key presses and stuff.
  277.  **********************************************************/
  278. void BBcdev::Key(short theKey)
  279. {
  280.     if (((theKey < '0') || (theKey > '9')) && (theKey != 8)
  281.                         && (theKey != 9) && ((theKey < 28) || (theKey > 31))) {
  282.         event->what = nullEvent;
  283.         return;
  284.     }
  285.     
  286.     /* if we got this far, then we have a reasonably valid keystroke */
  287.     mustRemember = true;
  288. }
  289.  
  290.  
  291.  
  292. /**********************************************************
  293.  *    BBcdev::ItemHit
  294.  *
  295.  *    This handles dialog item hits.
  296.  **********************************************************/
  297. void BBcdev::ItemHit(short theItem)
  298. {
  299.     ControlHandle    theControl;
  300.     short            controlValue;
  301.     Rect            box, save;
  302.     long            theLong, theTime = 0;
  303.     Str255            theString;
  304.  
  305.     GetDItem(dp, lastItem - initDev + theItem, &controlValue, &theControl, &box);
  306.     switch (theItem) {
  307.  
  308.         case sleepNow:
  309.             GlobalToLocal(&event->where);
  310.             if (PtInRect(event->where, &smallSNRect[topLeftRect])
  311.                                             && neverSleepRect != topLeftRect)
  312.                 sleepNowRect = topLeftRect;
  313.             else if (PtInRect(event->where, &smallSNRect[topRightRect])
  314.                                             && neverSleepRect != topRightRect)
  315.                 sleepNowRect = topRightRect;
  316.             else if (PtInRect(event->where, &smallSNRect[botRightRect])
  317.                                             && neverSleepRect != botRightRect)
  318.                 sleepNowRect = botRightRect;
  319.             else if (PtInRect(event->where, &smallSNRect[botLeftRect])
  320.                                             && neverSleepRect != botLeftRect)
  321.                 sleepNowRect = botLeftRect;
  322.             else {
  323.                 SysBeep(5);
  324.                 break;
  325.             }
  326.             
  327.             SetDItem(dp, lastItem - initDev + sleepNow,
  328.                     controlValue, pictHandles[sleepNowRect], &box);
  329.             InsetRect(&box, 3, 3);
  330.             EraseRect(&box);
  331.             InsetRect(&box, -3, -3);
  332.             DrawPicture(pictHandles[sleepNowRect], &box);
  333.             RememberValues();
  334.             break;
  335.             
  336.         case neverSleep:
  337.             GlobalToLocal(&event->where);
  338.             if (PtInRect(event->where, &smallNSRect[topLeftRect])
  339.                                             && sleepNowRect != topLeftRect)
  340.                 neverSleepRect = topLeftRect;
  341.             else if (PtInRect(event->where, &smallNSRect[topRightRect])
  342.                                             && sleepNowRect != topRightRect)
  343.                 neverSleepRect = topRightRect;
  344.             else if (PtInRect(event->where, &smallNSRect[botRightRect])
  345.                                             && sleepNowRect != botRightRect)
  346.                 neverSleepRect = botRightRect;
  347.             else if (PtInRect(event->where, &smallNSRect[botLeftRect])
  348.                                             && sleepNowRect != botLeftRect)
  349.                 neverSleepRect = botLeftRect;
  350.             else {
  351.                 SysBeep(5);
  352.                 break;
  353.             }
  354.             
  355.             SetDItem(dp, lastItem - initDev + neverSleep,
  356.                     controlValue, pictHandles[neverSleepRect], &box);
  357.             InsetRect(&box, 3, 3);
  358.             EraseRect(&box);
  359.             InsetRect(&box, -3, -3);
  360.             DrawPicture(pictHandles[neverSleepRect], &box);
  361.             RememberValues();
  362.             break;
  363.  
  364.         case idleRect:
  365.             if (Gestalt('sysv', &theLong) != noErr && theLong < 0x700)
  366.                 break;
  367.             save = box;
  368.             GlobalToLocal(&event->where);
  369.             GetDItem(dp, lastItem - initDev + idleMins,
  370.                             &controlValue, &theControl, &box);
  371.             GetIText(theControl, theString);
  372.             StringToNum(theString, &theLong);
  373.             theTime = Ticks - 16;
  374.             if (PtInRect(event->where, &smIdleRect)) {            // higher!!!
  375.                 DrawPicture(pictHandles[upArrow], &save);
  376.                 SelIText(dp, lastItem - initDev + idleMins, 0, 32767);
  377.                 do {
  378.                     SystemTask();
  379.                     if (Ticks - theTime > 15) {
  380.                         theTime = Ticks;
  381.                         if (theLong < 10) {
  382.                             NumToString(theLong += 1, theString);
  383.                             SetIText(theControl, theString);
  384.                             if (theLong == 10)
  385.                                 SelIText(dp, lastItem - initDev + idleMins, 0, 32767);
  386.                         } else if (theLong < 60) {
  387.                             NumToString(theLong += 5, theString);
  388.                             SetIText(theControl, theString);
  389.                         }
  390.                     }
  391.                 } while (Button());
  392.             } else {                                            // lower.
  393.                 DrawPicture(pictHandles[dnArrow], &save);
  394.                 SelIText(dp, lastItem - initDev + idleMins, 0, 32767);
  395.                 do {
  396.                     SystemTask();
  397.                     if (Ticks - theTime > 15) {
  398.                         theTime = Ticks;
  399.                         if (theLong > 10) {
  400.                             NumToString(theLong -= 5, theString);
  401.                             SetIText(theControl, theString);
  402.                         } else if (theLong > 1) {
  403.                                 NumToString(theLong -= 1, theString);
  404.                                 SetIText(theControl, theString);
  405.                         }
  406.                     }
  407.                 } while (Button());
  408.             }
  409.             box = save;
  410.             box.left += 3;
  411.             box.right -= 3;
  412.             box.top += 3;
  413.             box.bottom -= 3;
  414.             EraseRect(&box);
  415.             DrawPicture(pictHandles[noArrow], &save);
  416.             RememberValues();
  417.             break;
  418.  
  419.         case refrRect:
  420.             if (Gestalt('sysv', &theLong) != noErr && theLong < 0x700)
  421.                 break;
  422.             save = box;
  423.             GlobalToLocal(&event->where);
  424.             GetDItem(dp, lastItem - initDev + refreshSecs,
  425.                             &controlValue, &theControl, &box);
  426.             GetIText(theControl, theString);
  427.             StringToNum(theString, &theLong);
  428.             theTime = Ticks - 16;
  429.             if (PtInRect(event->where, &smRefrRect)) {            // higher!!!
  430.                 DrawPicture(pictHandles[upArrow], &save);
  431.                 SelIText(dp, lastItem - initDev + refreshSecs, 0, 32767);
  432.                 do {
  433.                     SystemTask();
  434.                     if (Ticks - theTime > 15) {
  435.                         theTime = Ticks;
  436.                         if (theLong < 20) {
  437.                             NumToString(theLong += 1, theString);
  438.                             SetIText(theControl, theString);
  439.                             if (theLong == 10)
  440.                                 SelIText(dp, lastItem - initDev + refreshSecs, 0, 32767);
  441.                         }                    }
  442.                 } while (Button());
  443.             } else {                                            // lower.
  444.                 DrawPicture(pictHandles[dnArrow], &save);
  445.                 SelIText(dp, lastItem - initDev + refreshSecs, 0, 32767);
  446.                 do {
  447.                     SystemTask();
  448.                     if (Ticks - theTime > 15) {
  449.                         theTime = Ticks;
  450.                         if (theLong > 1) {
  451.                             NumToString(theLong -= 1, theString);
  452.                             SetIText(theControl, theString);
  453.                         }
  454.                     }
  455.                 } while (Button());
  456.             }
  457.             box = save;
  458.             box.left += 3;
  459.             box.right -= 3;
  460.             box.top += 3;
  461.             box.bottom -= 3;
  462.             EraseRect(&box);
  463.             DrawPicture(pictHandles[noArrow], &save);
  464.             RememberValues();
  465.             break;
  466.  
  467.         case screenOn:
  468.         case clockOn:
  469.         case startupIcon:
  470.         case fadeWhite:
  471.         case zeroMenu:
  472.         case eraseRect:
  473.         case eraseOval:
  474.         case eraseRgn:
  475.         case drawMenu:
  476.         case initCurs:
  477.             controlValue = GetCtlValue(theControl);
  478.             controlValue = !controlValue;
  479.             SetCtlValue(theControl, controlValue);
  480.             RememberValues();
  481.             break;
  482.  
  483.         default:
  484.             break;
  485.     }
  486. }
  487.  
  488.  
  489.  
  490. /**********************************************************
  491.  *    BBcdev::RememberValues
  492.  *
  493.  *    This saves the information in the CNFG resource, and,
  494.  *    if the Basic Black INIT is loaded, sets the values of
  495.  *    its patch globals in memory.
  496.  **********************************************************/
  497. void BBcdev::RememberValues(void)
  498. {
  499.     PrefStructureHandle    prefHandle;
  500.     ControlHandle        theControl;
  501.     short                controlValue;
  502.     long                theLong;
  503.     Rect                box;
  504.     Str255                theString;
  505.     PatchGlobalsPtr        pgPtr;
  506.  
  507.     /* load in the first 'PREF' resource */
  508.     prefHandle = (PrefStructureHandle) GetIndResource('PREF', 1);
  509.  
  510.     /* save the idle time information */
  511.     GetDItem(dp, lastItem - initDev + idleMins, &controlValue, &theControl, &box);
  512.     GetIText(theControl, theString);
  513.     StringToNum(theString, &theLong);
  514.     (**prefHandle).idleTime = (short) theLong;
  515.  
  516.     /* save the refresh time information */
  517.     GetDItem(dp, lastItem - initDev + refreshSecs, &controlValue, &theControl, &box);
  518.     GetIText(theControl, theString);
  519.     StringToNum(theString, &theLong);
  520.     (**prefHandle).refreshSeconds = (short) theLong;
  521.  
  522.  
  523.     /* save the sleep corner information */
  524.     (**prefHandle).sleepNowCorner = sleepNowRect;
  525.     
  526.     /* save the wake corner information */
  527.     (**prefHandle).sleepNeverCorner = neverSleepRect;
  528.  
  529.     /* save the clock information */
  530.     GetDItem(dp, lastItem - initDev + clockOn, &controlValue, &theControl, &box);
  531.     (**prefHandle).bounceClock = GetCtlValue(theControl);
  532.  
  533.     /* save the "screen saver on" information */
  534.     GetDItem(dp, lastItem - initDev + screenOn, &controlValue, &theControl, &box);
  535.     (**prefHandle).saverOn = GetCtlValue(theControl);
  536.  
  537.     /* save the "Startup Icon" information */
  538.     GetDItem(dp, lastItem - initDev + startupIcon, &controlValue, &theControl, &box);
  539.     (**prefHandle).showIcon = GetCtlValue(theControl);
  540.  
  541.     /* save the "Fade To White" information */
  542.     GetDItem(dp, lastItem - initDev + fadeWhite, &controlValue, &theControl, &box);
  543.     (**prefHandle).fadeToWhite = GetCtlValue(theControl);
  544.  
  545.     /* save the "Zero Menu Bar" information */
  546.     GetDItem(dp, lastItem - initDev + zeroMenu, &controlValue, &theControl, &box);
  547.     (**prefHandle).zeroBar = GetCtlValue(theControl);
  548.  
  549.     /* save the "EraseRect" information */
  550.     GetDItem(dp, lastItem - initDev + eraseRect, &controlValue, &theControl, &box);
  551.     (**prefHandle).eraseRectPatch = GetCtlValue(theControl);
  552.  
  553.     /* save the "EraseOval" information */
  554.     GetDItem(dp, lastItem - initDev + eraseOval, &controlValue, &theControl, &box);
  555.     (**prefHandle).eraseOvalPatch = GetCtlValue(theControl);
  556.  
  557.     /* save the "EraseRgn" information */
  558.     GetDItem(dp, lastItem - initDev + eraseRgn, &controlValue, &theControl, &box);
  559.     (**prefHandle).eraseRgnPatch = GetCtlValue(theControl);
  560.  
  561.     /* save the "DrawMenuBar" information */
  562.     GetDItem(dp, lastItem - initDev + drawMenu, &controlValue, &theControl, &box);
  563.     (**prefHandle).drawMenuBarPatch = GetCtlValue(theControl);
  564.  
  565.     /* save the "InitCursor" information */
  566.     GetDItem(dp, lastItem - initDev + initCurs, &controlValue, &theControl, &box);
  567.     (**prefHandle).initCursorPatch = GetCtlValue(theControl);
  568.  
  569.     /* If the extension's installed, then update it's patch globals */
  570.     if (Gestalt('BBlk', (long *) &pgPtr) == noErr) {
  571.         if (pgPtr->pgVersion == (**prefHandle).version) {
  572.             pgPtr->pgMustSleep = false;
  573.             pgPtr->pgSleepRect = (**prefHandle).sleepNowCorner;
  574.             pgPtr->pgWakeRect = (**prefHandle).sleepNeverCorner;
  575.             pgPtr->pgIdleTicks = (long) (**prefHandle).idleTime * 3600;
  576.             pgPtr->pgBouncingClock = (**prefHandle).bounceClock;
  577.             pgPtr->pgMustSave = (**prefHandle).saverOn;
  578.             pgPtr->pgRefreshTime = (**prefHandle).refreshSeconds * 60;
  579.             if ((**prefHandle).fadeToWhite) {                // Fade to white
  580.                 StuffHex(&(pgPtr->pgForePat), "\pFFFFFFFFFFFFFFFF");
  581.                 StuffHex(&(pgPtr->pgBackPat), "\p0000000000000000");
  582.             } else {                                        // Fade to black
  583.                 StuffHex(&(pgPtr->pgForePat), "\p0000000000000000");
  584.                 StuffHex(&(pgPtr->pgBackPat), "\pFFFFFFFFFFFFFFFF");
  585.             }
  586.         }
  587.     }
  588.  
  589.     ChangedResource(prefHandle);
  590.     WriteResource(prefHandle);
  591.     ReleaseResource(prefHandle);
  592. }
  593.